package com.wongleoi.weather_demo.data

import com.wongleoi.weather_demo.api.ApiServices
import com.wongleoi.weather_demo.model.Weather


class WeatherRepository(private val apiServices: ApiServices = ApiServices.apiServices) {

    suspend fun weatherInfo(key: String,
                             city: String,
                             extensions: String,
                             output: String): List<Weather> {
        val response = apiServices.weatherInfo(key, city, extensions, output)
        if(response.status.toInt()!=1) {
            throw Exception(response.info)
        }
        return response.forecasts ?: emptyList()
    }

}